﻿@model Ninesky.Models.Category
@section Aside
    {
    @await Html.PartialAsync("AsidePartial")
}

<ol class="breadcrumb">
    <li><span class="glyphicon glyphicon-home"></span>  <a asp-controller="Hone" asp-action="Index">首页</a></li>
    <li><a asp-controller="Category" asp-action="Index">栏目管理</a></li>
    <li class="active">编辑栏目</li>
</ol>

<div class="panel panel-default">
    <div class="panel-body">
        <form method="post" class="form-horizontal">
            <div asp-validation-summary="ModelOnly" class="text-danger"></div>
            <input type="hidden" asp-for="CategoryId">
            <div class="form-group" data-ns-group="all">
                <label asp-for="Type" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <select asp-for="Type" asp-items="Html.GetEnumSelectList<CategoryType>()" class="form-control" disabled></select>
                    <input type="hidden" asp-for="Type" />
                    <span asp-validation-for="Type" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="ParentId" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <div class="input-group">
                        <input type="text" asp-for="ParentId" class="form-control" readonly>
                        <div class="input-group-btn">
                            <button type="button" id="Input_ParentId_Text" class="btn btn-default" style="margin-left:auto;margin-right:auto">无</button>
                            <button type="button" id="Input_ParentId_Btn" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">选择 <span class="caret"></span></button>
                            <div id="Input_ParentId_Dropdown" class="dropdown-menu dropdown-menu-right">
                                <div>
                                    <ul id="Input_ParentId_Tree" class="ztree" data-ns-url="/Manage/Category/GetParentCategoryList"></ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <span asp-validation-for="ParentId" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Name" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="Name" class="form-control" />
                    <span asp-validation-for="Name" class="text-danger"></span>
                </div>

            </div>
            <div class="form-group">
                <label asp-for="PicUrl" class="control-label col-md-2 col-sm-2"></label>

                <div class="col-md-10 col-sm-10">
                    <input asp-for="PicUrl" class="form-control" />
                    <span asp-validation-for="PicUrl" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Meta_Keywords" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <textarea asp-for="Meta_Keywords" class="form-control"></textarea>
                    <span asp-validation-for="Meta_Keywords" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Meta_Description" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <textarea asp-for="Meta_Description" class="form-control"></textarea>
                    <span asp-validation-for="Meta_Description" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Description" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <textarea asp-for="Description" class="form-control"></textarea>
                    <span asp-validation-for="Description" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group" data-ns-group="all">
                <label asp-for="Target" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <select asp-for="Target" asp-items="Html.GetEnumSelectList<LinkTarget>()" class="form-control"></select>
                    <span asp-validation-for="Target" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="Order" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="Order" class="form-control" />
                    <span asp-validation-for="Order" class="text-danger"></span>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="View" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="View" class="form-control" />
                    <span asp-validation-for="View" class="text-danger"></span>
                </div>
            </div>
            <div id="general_inputbox">
                <div class="form-group" data-ns-group="all">
                    <label asp-for="ModuleType" class="control-label col-md-2 col-sm-2"></label>
                    <div class="col-md-10 col-sm-10">
                        <select asp-for="ModuleType" asp-items="Html.GetEnumSelectList<ModuleType>()" class="form-control">
                            <option value="0">未设置</option>
                        </select>
                        <span asp-validation-for="Target" class="text-danger"></span>
                    </div>
                </div>
                <div id="content_inputbox">
                    <div class="form-group">
                        <label asp-for="ContentView" class="control-label col-md-2 col-sm-2"></label>
                        <div class="col-md-10 col-sm-10">
                            <input asp-for="ContentView" class="form-control" />
                            <span asp-validation-for="ContentView" class="text-danger"></span>
                        </div>
                    </div>

                    <div class="form-group">
                        <label asp-for="ContentOrder" class="control-label col-md-2 col-sm-2"></label>
                        <div class="col-md-10 col-sm-10">
                            <select asp-for="ContentOrder" asp-items="Html.GetEnumSelectList<ContentOrder>()" class="form-control"></select>
                            <span asp-validation-for="ContentOrder" class="text-danger"></span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label asp-for="PageSize" class="control-label col-md-2 col-sm-2"></label>
                        <div class="col-md-10 col-sm-10">
                            <input asp-for="PageSize" class="form-control" />
                            <span asp-validation-for="PageSize" class="text-danger"></span>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label asp-for="ShowOnMenu" class="control-label col-md-2 col-sm-2"></label>
                <div class="col-md-10 col-sm-10">
                    <input asp-for="ShowOnMenu" />
                    <span asp-validation-for="ShowOnMenu" class="text-danger"></span>
                </div>
            </div>
            <div id="link_inputbox">
                <div class="form-group">
                    <label asp-for="LinkUrl" class="control-label col-md-2 col-sm-2"></label>
                    <div class="col-md-10 col-sm-10">
                        <input asp-for="LinkUrl" class="form-control" />
                        <span asp-validation-for="LinkUrl" class="text-danger"></span>
                    </div>
                </div>
            </div>
            <button type="submit" class="btn btn-primary col-md-offset-2 col-sm-offset-2">保存</button>
            <button type="button" id="btn_delete" asp-page-handler="Delete" asp-route-id="@Model.CategoryId" data-ns-retrun-url="/Manage/Category/Index" class="btn btn-danger">删除</button>
        </form>
    </div>
</div>

@section scripts{
    @await Html.PartialAsync("_ValidationScriptsPartial")
    <script src="~/lib/zTree/js/jquery.ztree.core.min.js"></script>
    <script src="~/lib/bootstrap3-dialog/dist/js/bootstrap-dialog.min.js"></script>
    <script src="~/areas/manage/default/js/category/aside.js"></script>
    <script src="~/areas/manage/default/js/category/common.js"></script>
    <script src="~/Manage/Default/Js/CategoryModify.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            //初始tree
            dropdownCategoryTree = $.fn.zTree.init($("#ParentId_Tree"), setting);
            dropdownCategoryTree.addNodes(null, { categoryId: 0, name: "无" });
            Input_Type();
            ModuleType();
            //选择按钮点击
            $("#ParentId_Btn").click(function () {
                $("#ParentId_Dropdown").show();
            });
            //类型选择事件
            $("#Type").change(function () {
                Input_Type();
            });

            //模型选择事件
            $("#ModuleType").change(function () {
                ModuleType();
            });
            //删除按钮

            $("#btn_delete").click(function () {
                BootstrapDialog.confirm({
                    title: '警告',
                    message: '确认删除栏目',
                    type: BootstrapDialog.TYPE_DANGER,
                    closable: true,
                    draggable: true,
                    btnCancelLabel: '取消',
                    btnOKLabel: '删除',
                    btnOKClass: 'btn-danger',
                    callback: function (result) {
                        if (result) {
                            $.post("@Url.Content("~/Manage/Category/Delete/"+Model.CategoryId)",null, function (result) {
                                BootstrapDialog.alert({
                                    title: '消息',
                                    message: result.message,
                                    type: BootstrapDialog.TYPE_WARNING,
                                    closable: true,
                                    draggable: true,
                                    buttonLabel: '确定',
                                    callback: function () {
                                        if (result.succeed) location.href = "@Url.Content("~/Manage/Category/Index")";
                                    }
                                });

                            });
                        }
                    }
                });
            });
        });
    </script>
}
@section css{
    <link href="~/lib/zTree/css/metroStyle/metroStyle.css" rel="stylesheet" />
    <link href="~/lib/bootstrap3-dialog/dist/css/bootstrap-dialog.min.css" rel="stylesheet" />
}